package com.supermap.business.cloud.assets.comm;

import com.alibaba.dubbo.config.annotation.Reference;
import com.supermap.dataservice.util.JSONUtils;
import com.supermap.dubbo.api.cloud.assets.comm.Comm;
import com.supermap.dubbo.api.cloud.assets.comm.CommService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @author aqua
 * @description
 * @date 2019年10月18 15:56
 * @email 1301584033@qq.com
 */
@Controller
@RequestMapping("/cloud/assets/comm")
public class CommController {
    @Reference(timeout = 10000)
    CommService commodityService;

    /**
     * @descrpt: 分页查询商品
     * @param: [name, stype, page, size]
     * @return: com.supermap.dataservice.util.JSONUtils
     * @author: chenchao
     * @date: 2019/10/18
     * @mail chenchaoaqua@qq.com
     */
    @GetMapping("/getCommodityPageList")
    @ResponseBody
   public JSONUtils getCommodityPageList(String name,Integer stype,Integer parenId,Integer page,Integer size){
       return  commodityService.getCommodityPageList( name, stype, parenId, page, size);
   }


    /**
     * @descrpt: 添加
     * @param: [stype, name, parenId, unit, conctent]
     * @return: com.supermap.dataservice.util.JSONUtils
     * @author: chenchao
     * @date: 2019/10/18
     * @mail chenchaoaqua@qq.com
     */
    @PutMapping("/putCommodity")
    @ResponseBody
    public JSONUtils putCommodity(Integer stype,String name,Integer parenId,Double price,String unit,String conctent){
        return  commodityService.putCommodity( stype, name, parenId,price, unit, conctent);
    }

    /**
     * @descrpt: 物资删除
     * @param: [id]
     * @return: com.supermap.dataservice.util.JSONUtils
     * @author: chenchao
     * @date: 2019/10/18
     * @mail chenchaoaqua@qq.com
     */
    @DeleteMapping("/delCommodity")
    @ResponseBody
    public JSONUtils delCommodity(Integer id){
        return  commodityService.delCommodity(id);
    }


    /**
     * @descrpt: 物资盘点
     * @param: []
     * @return: com.supermap.dataservice.util.JSONUtils
     * @author: chenchao
     * @date: 2019/10/18
     * @mail chenchaoaqua@qq.com
     */
    @GetMapping("/getCommodityCountList")
    @ResponseBody
    public JSONUtils getCommodityCountList(Integer pId,Integer limit){
        return  commodityService.getCommodityCountList( pId,limit);
    }


    /**
     * @descrpt: 物资分页查询商品
     * @param: [name, stype, page, size]
     * @return: com.supermap.dataservice.util.JSONUtils
     * @author: chenchao
     * @date: 2019/10/18
     * @mail chenchaoaqua@qq.com
     */
    @GetMapping("/getCommodityUsePageList")
    @ResponseBody
    public JSONUtils getCommodityUsePageList(String name,Integer state,Integer page,Integer size){
        return  commodityService.getCommodityUsePageList(name, state, page, size);
    }

    @PutMapping("/insertComm")
    @ResponseBody
    public  JSONUtils insertComm(@RequestBody Comm comm){
        return  commodityService.insertComm(comm);
    }
    /**
     * @descrpt: 审核
     * @param: [scontent, state]
     * @return: com.supermap.dataservice.util.JSONUtils
     * @author: chenchao
     * @date: 2019/10/18
     * @mail chenchaoaqua@qq.com
     */
    @PostMapping("/commodityAudit")
    @ResponseBody
    public JSONUtils commodityAudit(Integer id,String scontent,String suerId,Integer state){
        return  commodityService.commodityAudit( id,scontent,suerId, state);
    }


}
